﻿Imports MyIPBssLogic.AppConfig
Imports System.Xml.Serialization
Imports System.IO
Imports System.Xml
Imports System.Net
Imports System.Text
Imports System.Text.RegularExpressions

Public Class frmTestLibs

    Dim Conf As MyIPBssLogic.AppConfig.Configuration
    Private Shared FileConf As String = Path.Combine( _
                                    My.Application.Info.DirectoryPath, _
                                      "Conf.xml")
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If Conf Is Nothing Then
            Conf = ConfMngmnt.Load(FileConf)
            If Conf.MyIPMailConf.From.MailBox = "" Then
                MsgBox("First save a valid configuration")
                Exit Sub
            End If
        End If

        Dim MailSender As New MyIPBssLogic.MailSender(Conf.MyIPMailConf)
        If MailSender.SendMessage Then
            MsgBox("OK")
        Else
            MsgBox("False")
        End If






    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Conf = New MyIPBssLogic.AppConfig.Configuration

        Conf.MyIPMailConf.From.MailBox = "mymail@myispprovider.com"
        Conf.MyIPMailConf.From.User = "mymail@myispprovider.com"
        Conf.MyIPMailConf.From.DisplayName = "MyIP"
        Conf.MyIPMailConf.From.NameSever = "mail.myispprovider.com"
        Conf.MyIPMailConf.From.Password = "billgates"
        Conf.MyIPMailConf.From.Port = 25
        Conf.MyIPMailConf.From.Secure = True
        Conf.MyIPMailConf.From.TypeSever = "POP3"

        Conf.MyIPMailConf.To.MailBox = "destination@hotmail.es"

        Conf.MyIPMailConf.Email.Subject = "MyIP Changes"
        Conf.MyIPMailConf.Email.Body = "Body of message"

        ConfMngmnt.Save(FileConf, Conf)

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click


        Conf = ConfMngmnt.Load(FileConf)

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        MsgBox(MyIPBssLogic.NetLogicBuss.GetIpAdress("http://checkip.dyndns.org/"))



    End Sub

    
End Class
